[HEADER]
	VERSION		01.00.00.00
	DESCRIPTION Texture Example
	COPYRIGHT	Imagination Technologies Ltd
[/HEADER]

[TEXTURES] 
	FILE leaf 	leaf.pvr		LINEAR-LINEAR-LINEAR
	FILE marble maskmain.pvr   	LINEAR-LINEAR-LINEAR
[/TEXTURES]

[VERTEXSHADER]
	NAME 		MyVertexShader

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		attribute vec4	myVertex;
		attribute vec3	myNormal;
		attribute vec2	myUVMain;
		attribute vec2	myUVDetail;

		uniform mat4	myWVPMatrix;
		uniform mat3	myWorldViewIT;
		uniform vec3	myLightPos;

		varying float	DiffuseIntensity;
		varying vec2	texCoordinateMain;
		varying vec2	texCoordinateDetail;
		varying vec2	varEnvMap;

		void main(void)
		{
			gl_Position = myWVPMatrix * myVertex;
			vec3 transNormal = normalize(myWorldViewIT * myNormal);
			
			vec3 LightDirection = myLightPos -  myVertex.xyz;
			DiffuseIntensity = 0.5 + dot(transNormal, normalize(LightDirection)) * 0.5;
			texCoordinateMain	= myUVMain.st;
			texCoordinateDetail	= myUVDetail.st;
			varEnvMap = 0.5 + transNormal.xy * 0.5;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]
    
[FRAGMENTSHADER] 
	NAME 		MyFragmentShader 

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		uniform sampler2D sampler2d;
		uniform sampler2D envmap2d;
		varying float	DiffuseIntensity;
		varying vec2	texCoordinateMain;
		varying vec2	texCoordinateDetail;
		varying vec2	varEnvMap;

		void main (void)
		{
			vec4 envColour = 0.5 * texture2D(envmap2d, varEnvMap);
			gl_FragColor = texture2D(sampler2d, texCoordinateMain) * texture2D(sampler2d, texCoordinateDetail) * (DiffuseIntensity + envColour);
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]
 
[EFFECT] 
	NAME 	ReflectionEffect

	UNIFORM myWorldViewIT 		WORLDVIEWIT
	UNIFORM myWVPMatrix 		WORLDVIEWPROJECTION
	UNIFORM	myLightPos			LIGHTPOSMODEL0
	UNIFORM	sampler2d			TEXTURE0
	UNIFORM	envmap2d			TEXTURE1
	
	ATTRIBUTE myVertex			POSITION
	ATTRIBUTE myNormal			NORMAL
	ATTRIBUTE myUVMain			UV0
	ATTRIBUTE myUVDetail		UV1

   	VERTEXSHADER MyVertexShader
   	FRAGMENTSHADER MyFragmentShader
   	
	TEXTURE 0 marble
	TEXTURE 1 leaf
[/EFFECT]
